﻿using System;
using System.Data;
using System.Windows.Controls;
using SLS.Controls;
using SLS.ExClassLib.Event;
using SLS.ExClassLib.Events;
using SLS.ExClassLib.Message;
using SLS.Base;
using SLS.ExClassLib.RTIService;
namespace SLS.Document
{
    public class DocumentAddress 
    {
        public string Address;
        public string DocType;
        public object doc;
       public  DocumentAddress()
        { }
        public DocumentAddress(string _DocType, string _Address, object _doc)
        {
            DocType = _DocType;
            Address = _Address;
            doc = _doc;
        } 
    }
    public partial class DocumentManagement
    {
        public void SendJobForProcessing(DataSet setEvent, SLBC sdoc, string type = "Edit", bool flagStartQueryUI = false, bool IsCheckDataQuality = false)
        {
            try
            { 
                    if (setEvent.Tables.Count == 0)
                        return;
                    string TBName = setEvent.Tables[0].TableName;
                    string DocType = type + TBName;
                    SLBC doc; 
                    doc = OpenDocument(DocType, ClientWFManagerAddress, "TAB_MAIN", "TxTablControl"); 
                    MessageEx msg = new MessageEx();
                    msg.JobID = "OnSendJobForProcessing";
                    msg.setEvent = setEvent;
                    msg.Federation = "WFFederation";
                    msg.Tag = "YES";
                    msg.JobType = "UI2WF";
                    msg.TimeStamp = ContactRTIService.Instance.GetRTITimeStamp(msg);
                    msg.Address = doc.Address;
                    msg.Tag= IsCheckDataQuality;
                    EventDispatcher.Instance.Publish(msg, null, EventType.UI2WF);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }

        }
        public void Append(SLBC doc, string doctype, ExTabControl sofa)
        {
            try
            {
                TabItem tabItemi; 
                doc.Name = doctype.ToLower();
                tabItemi = new TabItem();
                string header = doctype;
                tabItemi.Header = header;
                tabItemi.Name = doc.Address;
                sofa.Items.Add(tabItemi);
                tabItemi.Content = doc;
                DocumentAddress docadd = new DocumentAddress(doctype, doc.Address, doc);
                DocumentList.Add(docadd);  
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
     }   
    }
 
 
